<template>
     <el-card v-loading="loading" shadow="never" body-style="padding: 24px;" class="card-margin">
            <h1 class="condition-title">{{ $t('culture.cultureScheme.linkPlan') }}</h1>
            <!-- <schemePreview
                v-if="show"
                :template-id="scheme.schemeId"
                :scheme="scheme"
                :data-type="2"
            />-->
            <schemePreview :id="id" v-if="show" :data-type="2"/>
            <!--未绑定培养方案-->
            <div v-else>
                <div class="no-culture-plan"></div>
                <div
                    style="text-align:center;margin-bottom:100px"
                >{{$t('culturePlan.noCultureTip')}}</div>
            </div>
        </el-card>
</template>

<script>
import * as API from "common/src/api/culture/cultruescheme";
import schemePreview from "../culturescheme/schemePreview";

export default {
    name: "myCultureScheme",
    components: {
        schemePreview
    },
    data() {
        return {
            loading: false,
            show: false,
            // scheme: {
            //     templateId: "",
            //     schemeId: ""
            // }
            id: ""
        };
    },
    created() {
        this.getCoutureScheme();
    },
    methods: {
        getCoutureScheme() {
            API.getMyCultureScheme()
                .then(res => {
                    if (res.code == 200) {
                        // this.scheme.templateId = res.data.cultureId;
                        // this.scheme.schemeId = res.data.cultureId;
                        if(res.data == null){
                            this.show = false;
                        }else{
                            this.show = true;
                            this.id = res.data && res.data.cultureId;
                        }
                    }
                })
                // .catch(err => {
                //     console.log(err);
                // });
        }
    }
};
</script>

<style scoped>
.no-culture-plan {
    background: url("/static/images/no-cultureplan.png");
    width: 444px;
    height: 249px;
    margin: 20px auto 40px;
}
</style>
